<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>档案管理系统</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">

    <link rel="stylesheet" href="/static/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="/static/dist/css/font-awesome.min.css">
    <link rel="stylesheet" href="/static/dist/css/ionicons.min.css">
    <link rel="stylesheet" href="/static/dist/css/AdminLTE.min.css">
    <link rel="stylesheet" href="/static/dist/css/skins/all-skins.min.css">
    <link rel="stylesheet" href="/static/css/bootstrap-treeview.css">
    <link rel="stylesheet" href="/static/css/bootstrapValidator.min.css">
    <link rel="stylesheet" href="/static/layer/theme/default/layer.css">
    <link rel="stylesheet" href="/static/css/fileinput.min.css">
    <link rel="stylesheet" href="/static/css/bootstrap-table.min.css">

    <style type="text/css">
        .nav-tabs-custom{
            box-shadow:0 0px 0px rgba(255, 255, 255, 1)!important;
        }
        .table>tbody>tr>td{
            border-left: 0px;
            border-right: 0px;
            border-bottom: 1px solid #e5e9ee;
        }
        /*.table{border: 1px solid #e5e9ee; }*/

        .table thead{
            line-height:17px;
            border: 1px solid #e5e9ee;
            background-color: #F9F9F9;
            color: #777777;
            font-family: PingFang SC;
        }
        html {
            /*overflow: hidden;*/
        }
    </style>
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="/static/plugins/ie9/html5shiv.min.js"></script>
    <script src="/static/plugins/ie9/respond.min.js"></script>
    <![endif]-->
</head>
<body class="hold-transition skin-blue"  style="font-size: medium">
        <div class="content row" id="lxgl">
            <div class="modal" id="lxxzModal" data-backdrop="static">
                <div class="modal-dialog" style="height: 500px">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                <span aria-hidden="true">&times;</span></button>
                            <h4 class="modal-title">选择档案类型</h4>
                        </div>
                        <div class="modal-body">
                            <div id="lxTree"></div>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default pull-left" data-dismiss="modal">关闭</button>
                            <button @click="sureLxSelect" type="button" class="btn btn-primary">确认选择</button>
                        </div>
                    </div>
                    <!-- /.modal-content -->
                </div>
                <!-- /.modal-dialog -->
            </div>
            <div class="modal" id="filesModal" data-backdrop="static">
                <div class="modal-dialog" style="height: 500px">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                <span aria-hidden="true">&times;</span></button>
                            <h4 class="modal-title">上传文件夹</h4>
                        </div>
                        <div class="modal-body">
                            <div class="input-group">
                                <div class="custom-file">
                                    <input @change="filesChange" id="fileUpload" type="file" multiple webkitdirectory class="custom-file-input" ref="fileUpload">
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default pull-left" data-dismiss="modal">关闭</button>
                            <button @click.prevent="doUploadFiles" type="submit" class="btn btn-primary" :disabled="zzsc">上传该文件夹</button>
                        </div>
                    </div>
                    <!-- /.modal-content -->
                </div>
                <!-- /.modal-dialog -->
            </div>
            <div class=" col-xs-12">
                <div style="height: 800px">
                    <!--<div class="box-header with-border">-->
                        <!--<h3 class="box-title">材料信息补录</h3>-->
                    <!--</div>-->
                    <div class="nav-tabs-custom">
                        <ul class="nav nav-tabs pull-right">
                            <li style="float: left" class="active"><a href="#clxxbr" data-toggle="tab">材料信息补入</a></li>
                            <li style="float: left"><a href="#xgxx" data-toggle="tab">已录信息</a></li>
                        </ul>
                        <div class="tab-content no-padding">
                            <div class="tab-pane active" id="clxxbr"
                                 style="position: relative; height: auto">
                                <form role="form" style="width: 100%">
                                    <div class="box-body">
                                        <div class="nav-tabs-custom">
                                            <!-- Tabs within a box -->
                                            <ul class="nav nav-tabs pull-right">
                                                <!--<li class="active"><a href="#revenue-chart" data-toggle="tab">Area</a></li>-->
                                                <!--<li><a href="#sales-chart" data-toggle="tab">Donut</a></li>-->
                                                <li class="pull-left header" style="color: #00a7d0"><i class="fa fa-inbox"></i> 基本信息</li>
                                            </ul>
                                            <div class="tab-content no-padding">
                                                <!-- Morris chart - Sales -->
                                                <div class="chart tab-pane active" style="position: relative">
                                                    <div class="row">
                                                        <div class="form-group col-xs-3">
                                                            <label class="text-danger">*档案类型</label>
                                                            <div>
                                                                <div class="input-group">
                                                                    <span class="input-group-addon btn btn-primary" data-toggle="modal" data-target="#lxxzModal" @click="clSelect">选择</span>
                                                                    <input type="text" class="form-control input-sm" v-model="dalxText" readonly>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="form-group col-xs-3">
                                                            <label class="text-danger">*档案编号</label>
                                                            <input @change="dabhChange" name="dabh" v-model="clxx.dabh" type="text" class="form-control input-sm">
                                                        </div>
                                                        <div class="form-group col-xs-3">
                                                            <label class="text-danger">*文件序号</label>
                                                            <input name="wjxh" v-model="clxx.wjxh" type="text" class="form-control input-sm" @change="wjxhchange">
                                                        </div>
                                                        <div class="form-group col-xs-3">
                                                            <label class="text-danger">*材料名称</label>
                                                            <input name="clmc" v-model="clxx.clmc" type="text" class="form-control input-sm" @change="clmcchange">
                                                        </div>
                                                        <div class="form-group col-xs-3">
                                                            <label>起始页码</label>
                                                            <input name="qsym" v-model="clxx.qsym" type="text" class="form-control input-sm">
                                                        </div>
                                                        <div class="form-group col-xs-3">
                                                            <label>终止页码</label>
                                                            <input name="zzym" v-model="clxx.zzym" type="text" class="form-control input-sm">
                                                        </div>
                                                        <div class="form-group col-xs-3">
                                                            <label>页数</label>
                                                            <input name="ys" v-model="clxx.ys" type="text" class="form-control input-sm">
                                                        </div>
                                                    </div>
                                                </div>
                                                <!--<div class="chart tab-pane" id="sales-chart" style="position: relative; height: 300px;"></div>-->
                                            </div>
                                        </div>
                                        <div class="nav-tabs-custom">
                                            <!-- Tabs within a box -->
                                            <ul class="nav nav-tabs pull-right">
                                                <!--<li class="active"><a href="#revenue-chart" data-toggle="tab">Area</a></li>-->
                                                <!--<li><a href="#sales-chart" data-toggle="tab">Donut</a></li>-->
                                                <li class="pull-left header" style="color: #00a7d0"><i class="fa fa-inbox"></i> 其他</li>
                                            </ul>
                                            <div class="tab-content no-padding">
                                                <!-- Morris chart - Sales -->
                                                <div class="chart tab-pane active" style="position: relative">
                                                    <div class="row">
                                                        <div class="form-group col-xs-3">
                                                            <label>份数</label>
                                                            <input name="fs" v-model="clxx.fs" type="text" class="form-control input-sm">
                                                        </div>
                                                        <div class="form-group col-xs-3">
                                                            <label>年份</label>
                                                            <input name="year" v-model="clxx.year" type="text" class="form-control input-sm">
                                                        </div>
                                                        <div class="form-group col-xs-3">
                                                            <label>案卷号/文号/许可证号</label>
                                                            <input name="otherZh" v-model="clxx.otherZh" type="text" class="form-control input-sm">
                                                        </div>
                                                        <div class="form-group col-xs-3">
                                                            <label>受理时间</label>
                                                            <input name="slsj" v-model="clxx.slsj" type="text" class="form-control input-sm">
                                                        </div>
                                                        <div class="form-group col-xs-12">
                                                            <label>备注</label>
                                                            <textarea class="form-control" v-model="clxx.bz" name="bz"></textarea>
                                                        </div>
                                                    </div>
                                                </div>
                                                <!--<div class="chart tab-pane" id="sales-chart" style="position: relative; height: 300px;"></div>-->
                                            </div>
                                        </div>
                                    </div>
                                    <div class="box-body row">
                                        <div class="text-center col-xs-12">
                                            <button @click.prevent="mySubmit" class="btn btn-primary" :disabled="zzmySubmit">提交</button>
                                            <span @click.prevent="scFiles" class="btn btn-primary">上传文件夹</span>
                                        </div>
                                        <!--<div v-show="hide">-->
                                        <!--<div class="form-group col-xs-4">-->
                                        <!--<label>上传多个文件</label>-->
                                        <!--<input ref="fileUpload" id="inputFile2" type="file" class="file"-->
                                        <!--data-show-preview="false"-->
                                        <!--data-show-upload="false" name="files" multiple webkitdirectory disabled>-->
                                        <!--&lt;!&ndash;<div class="text-center">&ndash;&gt;-->
                                        <!--&lt;!&ndash;<button @click.prevent="mySubmitwj" type="submit" class="btn btn-primary">上传文件夹&ndash;&gt;-->
                                        <!--&lt;!&ndash;</button>&ndash;&gt;-->
                                        <!--&lt;!&ndash;</div>&ndash;&gt;-->
                                        <!--</div>-->
                                        <!--<div class="form-group col-xs-4">-->
                                        <!--<label>上传pdf文件</label>-->
                                        <!--<input ref="fileUpload" id="inputPDF2" type="file" class="file" data-show-preview="false"-->
                                        <!--data-show-upload="false" name="files" accept="application/pdf" disabled>-->
                                        <!--&lt;!&ndash;<div class="text-center">&ndash;&gt;-->
                                        <!--&lt;!&ndash;<button @click.prevent="mySubmitPDF" type="submit" class="btn btn-primary">上传PDF&ndash;&gt;-->
                                        <!--&lt;!&ndash;</button>&ndash;&gt;-->
                                        <!--&lt;!&ndash;</div>&ndash;&gt;-->
                                        <!--</div>-->
                                        <!--</div>-->
                                        <!--<div v-show="show">-->
                                        <!--<div class="form-group col-xs-4">-->
                                        <!--<label>上传多个文件</label>-->
                                        <!--<input ref="fileUpload" id="inputFile" type="file" class="file"-->
                                        <!--data-show-preview="false"-->
                                        <!--data-show-upload="false" name="files" multiple webkitdirectory>-->
                                        <!--&lt;!&ndash;<div class="text-center">&ndash;&gt;-->
                                        <!--&lt;!&ndash;<button @click.prevent="mySubmitwj" type="submit" class="btn btn-primary">上传文件夹&ndash;&gt;-->
                                        <!--&lt;!&ndash;</button>&ndash;&gt;-->
                                        <!--&lt;!&ndash;</div>&ndash;&gt;-->
                                        <!--</div>-->
                                        <!--&lt;!&ndash;<div class="form-group col-xs-4">&ndash;&gt;-->
                                        <!--&lt;!&ndash;<label>上传多个文件</label>&ndash;&gt;-->
                                        <!--&lt;!&ndash;<input ref="fileUpload" id="inputFile" type="file" class="file"&ndash;&gt;-->
                                        <!--&lt;!&ndash;data-show-preview="false"&ndash;&gt;-->
                                        <!--&lt;!&ndash;data-show-upload="false" name="files" multiple webkitdirectory>&ndash;&gt;-->
                                        <!--&lt;!&ndash;&lt;!&ndash;<div class="text-center">&ndash;&gt;&ndash;&gt;-->
                                        <!--&lt;!&ndash;&lt;!&ndash;<button @click.prevent="mySubmitwj" type="submit" class="btn btn-primary">上传文件夹&ndash;&gt;&ndash;&gt;-->
                                        <!--&lt;!&ndash;&lt;!&ndash;</button>&ndash;&gt;&ndash;&gt;-->
                                        <!--&lt;!&ndash;&lt;!&ndash;</div>&ndash;&gt;&ndash;&gt;-->
                                        <!--&lt;!&ndash;</div>&ndash;&gt;-->
                                        <!--&lt;!&ndash;<div class="form-group col-xs-4">&ndash;&gt;-->
                                        <!--&lt;!&ndash;<label>上传pdf文件</label>&ndash;&gt;-->
                                        <!--&lt;!&ndash;<input ref="fileUpload" id="inputPDF" type="file" class="file" data-show-preview="false"&ndash;&gt;-->
                                        <!--&lt;!&ndash;data-show-upload="false" name="files" accept="application/pdf">&ndash;&gt;-->
                                        <!--&lt;!&ndash;&lt;!&ndash;<div class="text-center">&ndash;&gt;&ndash;&gt;-->
                                        <!--&lt;!&ndash;&lt;!&ndash;<button @click.prevent="mySubmitPDF" type="submit" class="btn btn-primary">上传PDF&ndash;&gt;&ndash;&gt;-->
                                        <!--&lt;!&ndash;&lt;!&ndash;</button>&ndash;&gt;&ndash;&gt;-->
                                        <!--&lt;!&ndash;&lt;!&ndash;</div>&ndash;&gt;&ndash;&gt;-->
                                        <!--&lt;!&ndash;</div>&ndash;&gt;-->
                                        <!--</div>-->

                                        <!--<div class="form-group col-xs-4">-->
                                        <!--<div class="text-center">-->
                                        <!--<label class="row"></label>-->
                                        <!--<button @click.prevent="sfcz" type="button" class="btn btn-primary">文件是否存在-->
                                        <!--</button>-->
                                        <!--</div>-->
                                        <!--</div>-->
                                    </div>
                                    <!-- /.box-body -->

                                    <div class="box-footer">

                                    </div>
                                </form>
                            </div>
                            <div class="tab-pane" id="xgxx" style="position: relative; height: 500px;overflow: auto">
                                <div class="text-center col-xs-12">
                                    <table class="table table-bordered table-hover text-center" id="clTable" style="table-layout: fixed;">

                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- /.box-header -->
                    <!-- form start -->
                </div>
            </div>
        </div>

<script src="/static/plugins/jQuery/jquery-2.2.3.min.js"></script>
<!-- Bootstrap 3.3.6 -->
<script src="/static/bootstrap/js/bootstrap.min.js"></script>
<!-- Slimscroll -->
<script src="/static/plugins/slimScroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="/static/plugins/fastclick/fastclick.js"></script>
<!-- AdminLTE App -->
<script src="/static/dist/js/app.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="/static/dist/js/demo.js"></script>
<!--tabs-->
<script src="/static/dist/js/app_iframe.js"></script>
<script src="/static/js/bootstrap-treeview.js"></script>
<script src="/static/js/bootstrapValidator.min.js"></script>
<script src="/static/js/vue.js"></script>
        <script src="/static/js/axios.min.js"></script>
<script src="/static/js/vue-resource.min.js"></script>
        <script src="/static/layer/layer.js"></script>
<script src="/static/js/myJs.js"></script>
<script src="/static/js/fileinput.min.js"></script>
<script src="/static/js/bootstrap-table.min.js"></script>
<script src="/static/js/bootstrap-table-zh-CN.js"></script>

<script type="text/javascript">
    function paramsMatter(value,row,index) {
        var span=document.createElement('span');
        span.setAttribute('title',value);
        span.innerHTML = value;
        return span.outerHTML;
    }
    var dabh;
    var dalx;
    var typeName;
    var typeId;
    var vue = new Vue({
        el:'#lxgl',
        data:{
            zzsc:false,
            zzmySubmit:false,
            upLoadFiles:null,
            files:null,
            scsmyj:{
                yjmc:null,
            },
            show:false,
            hide:true,
            //cz:"disabled",
            sccg:null,//上传成功
            parentLx:null,
            dalx:null,
            dalxText:null,
            clxx:{
                slsj:null,
                typeName:null,
                clmc:null,
                otherZh:null,
                dabh:null,
                typeId:null,
                wjxh:"001",
                //clmc:null,
                fs:null,
                qsym:null,
                zzym:null,
                ys:null,
                year:null,
                otherZh:null,
                bz:null
            }
        },
        methods:{
            clSelect:function(){
                this.$http.get('/dagl/api/queryDalx').then( function (result) {
                    var data = result.body;
                    if(data.code == 200){
                        $('#lxTree').treeview({
                            color: "#428bca",
                            collapseIcon: "glyphicon glyphicon-folder-open",//可收缩的节点图标
                            // nodeIcon: "glyphicon glyphicon-user",
                            emptyIcon: "glyphicon glyphicon-file",//设置列表树中没有子节点的节点的图标
                            expandIcon: "glyphicon glyphicon-folder-close",  //设置列表上中有子节点的图标
                            highlightSearchResults:true,//是否高亮搜索结果 默认true
                            highlightSelected:true,     //是否选中高亮显示
                            onhoverColor: "#f5f5f5",    //鼠标滑过的颜色
                            levels: 0 ,                 //设置初始化展开几级菜单 默认为2
                            //selectedIcon: 'glyphicon glyphicon-tint',
                            showBorder:true,                //是否显示边框
                            showCheckbox:false,              //是否显示多选框
                            data:data.data,
                            showTags:true,
                            onNodeSelected:function(event, data) {
                                vue.$data.dalxId = data.id;
                                vue.$data.dalxText = data.text;
                                vue.$data.clxx.typeId = data.id;
                                vue.$data.clxx.typeName = data.text;
                            }
                        });
                    }else{
                        cxAlert(data.mess);
                    }
                })
            },
            doUploadFiles:function(){
                dabh = this.clxx.dabh;
                dalx = this.dalxText;
                this.clxx.typeName = dalx;
                this.clxx.typeId = typeId;
                if(this.dalxText == null || this.clxx.dabh == null){
                    cxAlert("请先将档案类型和档案编号填写完整");
                    return;
                }
                if(this.files == null || this.files.length==0){
                    cxAlert("请选择要上传的文件夹");
                    return;
                }
                var data = new FormData();
                data.append('lb',this.dalxText);
                data.append('dah', this.clxx.dabh);
                for (var i = 0; i < this.files.length; i++) {
                    data.append('files', this.files[i])
                }
                //$('#shangchuan').modal('show');
                this.zzsc = false;
                this.$http.post('/api/upload/upLoadClxx', data, {
                    headers: {
                        'Content-Type': 'multipart/form-data',
                    },
                }).then(res => {
                    this.zzsc = true;
                    var data = res.body;
                    if(data.code == "200"){
                        typeName = this.clxx.typeName;
                        typeId = this.clxx.typeId;
                        cxAlertOk("文件夹上传成功");
                        $('#filesModal').modal('hide');
                        $("form").data('bootstrapValidator').resetForm();//清除当前验证的关键之处
                        Object.keys(this.clxx).forEach(key => (this.clxx[key] = null));
                        this.parentLx=null;
                        //this.dalx=null;
                        //this.dalxText = null;
                        this.clxx.dabh = dabh;
                        this.clxx.typeName = typeName;
                        this.clxx.typeId = typeId;
                        $("#clTable").bootstrapTable('destroy');
                        $('#clTable').bootstrapTable({
                            url: '/dalr/api/queryDabhClxx?dabh='+this.clxx.dabh,
                            contentType: "application/json; charset=UTF-8",
                            type: "GET",
                            dataType: 'json',
                            queryParamsType: "",
                            singleSelect: true,
                            paginationShowPageGo: true,
                            pageNumber:1,
                            pageSize:8,
                            queryParams: function (params) {
                                return {'pageNum':params.pageNumber,'pageSize':params.pageSize};
                            },
                            striped: true,
                            smartDisplay:false,
                            cache: false,
                            //pagination: true,
                            //pageList: [8],
                            sidePagination: 'server',
                            toolbar: "#addtool",
                            columns: [
                                {
                                    title: '档案类型',
                                    field:'typeName',
                                    formatter:paramsMatter
                                },{
                                    field: 'dabh',
                                    title: '档案编号',
                                    formatter:paramsMatter
                                },
                                {
                                    title: '文件序号',
                                    field:'wjxh',
                                    formatter:paramsMatter
                                },{
                                    field: 'clxxName',
                                    title: '材料名称',
                                    formatter:paramsMatter
                                }],
                            responseHandler: function (res) {  //后台返回的结果
                                if (res.code == "200") {
                                    var data = res.data;
                                    var NewData = [];
                                    for(i=0;i<data.length;i++){
                                        var dd = data[i];
                                        NewData.push(dd);
                                    }
                                    var data = {
                                        total: res.data.total,
                                        rows: NewData
                                    };
                                    return data;
                                }
                            }
                        });
                    }else{
                        cxAlert(data.mess);
                    }

                }).catch(err => {
                    console.log(err);
                });
            },
            filesChange:function(){
                this.upLoadFiles = [];
                this.files = [];
                this.scsmyj.yjmc=[];
                var temp = [];
                this.upLoadFiles = [];
                var fileUpload = this.$refs.fileUpload;
                var file = fileUpload.files;
                var tempFile=[];
                for(i = 0; i < file.length; i++){
                    var f = file[i];
                    tempFile.push(f);
                    // if(f.name.toLowerCase().indexOf(".jpg") != -1 || f.name.toLowerCase().indexOf(".png") != -1 || f.name.toLowerCase().indexOf(".bmp") != -1 || f.name.toLowerCase().indexOf(".pdf") != -1){
                    //
                    // }
                }
                this.files = tempFile;
                //this.gdxx.zys = tempFile.length;
                for (i = 0; i < tempFile.length; i++) {
                    var f = tempFile[i];
                    var path = f.webkitRelativePath;
                    data={};
                    data['id']=i+1;
                    var lastPath = path.lastIndexOf("/");
                    var lastPath2= path.substring(0,lastPath).lastIndexOf("/");
                    if(lastPath2){
                        data['yjmc'] = path.substring(lastPath2+1,lastPath);
                        temp.push(path.substring(lastPath2+1,lastPath));
                    }else {
                        temp.push(path.substring(0,path.lastIndexOf("/")));
                    }
                    //this.clxx.dabh = path.substring(0,path.indexOf("/"));
                    data['wjmc'] = f.name;
                    this.upLoadFiles.push(data);
                    this.scsmyj.yjmc = data['yjmc'];
                }
                this.scsmyj.yjmc = temp;
                //this.doUploadFiles();
            },

            scwjj:function(){
            },
            //上传文件夹
            scFiles:function(){
                $("#filesModal").modal('show');
            },
            clmcchange:function(){
                this.show = false;
                this.hide =true;
            },
            wjxhchange:function(){
                this.show = false;
                this.hide =true;
            },
            sfcz:function(){
                var clname = vue.$data.clxx.clmc;
                var lb = vue.$data.dalxText;
                var dabh = vue.$data.clxx.dabh;
                var wjxh = vue.$data.clxx.wjxh;
                this.$http.get('/dalr/api/getFlagClxx?clname='+clname+'&lb='+lb+'&dabh='+dabh+'&wjxh='+wjxh).then( function (result) {
                    var data = result.body;
                    if (data.code == 200&&!data.data) {
                        cxAlert("该文件不存在")
                        this.show = true;
                        this.hide =false;
                    }else{

                        this.show = false;
                        this.hide =true;
                        cxAlert("该文件已存在");
                    }
                });
            },
            mySubmitwj :function () {
                let data2 = vue.$data.clxx;
                if(data2.typeId != null&&data2.dabh != null&&data2.clmc && data2.wjxh){
                    var fileUpload2 = $("input[id='inputFile']");
                    var file2 = fileUpload2[0].files;
                    var data = new FormData();
                    let clname = vue.$data.clxx.clmc;
                    let lb = vue.$data.dalxText;
                    let dabh = vue.$data.clxx.dabh;
                    let wjxh = vue.$data.clxx.wjxh;
                    data.append('clname',clname);
                    data.append('lb',lb);
                    data.append('dabh',dabh);
                    data.append('wjxh',wjxh);

                    if(file2.length == 0){
                        cxAlert("请先选择要上传的文件");
                    }else{
                        for (var i = 0; i < file2.length; i++) {
                            data.append('files',file2[i]);

                        }
                        //console.log(vue.$data.wsxx.files);
                        //let files2 = vue.$data.wsxx.files;

                        //data.append('files', vue.$data.wsxx.files);

                        //vue.$data.files = data;
                        //let files = vue.$data.files;
                        //console.log(data);
                        var myMsg = cxLoad("上传中");
                        this.$http.post('/dalr/api/uploadWsCls', data, {
                            headers: {
                                'Content-Type': 'multipart/form-data',
                            },
                        }).then(function (result) {
                            var data = result.body;
                            layer.close(myMsg);
                            if (data.code == 200) {
                                cxAlert("上传成功");
                                this.sccg = true;
                                $(".fileinput-remove-button").click();
                            } else {
                                cxAlert(data.mess);
                                this.sccg = false;
                            }
                        });
                    }
                }else{
                    cxAlert("请先将必填字段填写完毕");
                    this.sccg = false;
                }
            },
            mySubmitPDF:function () {
                let data2 = vue.$data.clxx;
                if (data2.typeId != null && data2.dabh != null && data2.clmc && data2.wjxh) {
                    var fileUpload = this.$refs.fileUpload;
                    var file = fileUpload.files;
                    var data = new FormData();
                    let lb = vue.$data.dalxText;
                    let dabh = vue.$data.clxx.dabh;
                    data.append('lb', lb);
                    data.append('dabh', dabh);
                    //data.append('file', file);
                    for (var i = 0; i < file.length; i++) {
                        data.append('file', file[i])
                    }
                    var myMsg = cxLoad("上传中");
                    this.$http.post('/dalr/api/uploadWsCl',data).then(function (result) {
                        var data = result.body;
                        layer.close(myMsg);
                        if (data.code == 200) {
                            cxAlertOk("上传成功");
                            $(".fileinput-remove-button").click();
                        } else {
                            cxAlert(data.mess);
                        }
                    });
                } else {
                    cxAlert("请先将必填字段填写完毕");
                    this.sccg = false;
                }
            },
            dabhChange:function(){
                this.show = false;
                this.hide = true;
                var bh = this.clxx.dabh;
                var datas = bh.split("-");
                //this.clxx.qzh = datas[0];
                //this.clxx.year = datas[1];
                var code = datas[0];
                code = datas[0].substring(0,code.length-4)
                this.$http.get('/dagl/api/queryCode?code='+code).then( function (result) {
                    var data = result.body;
                    if (data.code == 200) {
                        this.parentLx = data.data.id;
                        this.dalx = data.data.id;
                        this.dalxText = data.data.dalxName;
                        this.clxx.typeId = data.data.id;
                        typeId = this.clxx.typeId;
                        this.clxx.typeName = data.data.dalxName;
                    }else{
                        cxAlert("该编号不符合要求");
                        this.clxx.dabh = null;
                        $("form").data('bootstrapValidator').resetForm();//清除当前验证的关键之处
                    }
                });
                $("#clTable").bootstrapTable('destroy');
                $('#clTable').bootstrapTable({
                    url: '/dalr/api/queryDabhClxx?dabh='+this.clxx.dabh,
                    contentType: "application/json; charset=UTF-8",
                    type: "GET",
                    dataType: 'json',
                    queryParamsType: "",
                    singleSelect: true,
                    paginationShowPageGo: true,
                    pageNumber:1,
                    pageSize:8,
                    queryParams: function (params) {
                        return {'pageNum':params.pageNumber,'pageSize':params.pageSize};
                    },
                    striped: true,
                    smartDisplay:false,
                    cache: false,
                    //pagination: true,
                    //pageList: [8],
                    sidePagination: 'server',
                    toolbar: "#addtool",
                    columns: [{
                        title: '档案类型',
                        field:'typeName',
                        formatter:paramsMatter
                    },{
                        field: 'dabh',
                        title: '档案编号',
                        formatter:paramsMatter
                    },
                        {
                            title: '文件序号',
                            field:'wjxh',
                            formatter:paramsMatter
                        },{
                            field: 'clxxName',
                            title: '材料名称',
                            formatter:paramsMatter
                        }],
                    responseHandler: function (res) {  //后台返回的结果
                        if (res.code == "200") {
                            var data = res.data;
                            var NewData = [];
                            for(i=0;i<data.length;i++){
                                var dd = data[i];
                                NewData.push(dd);
                            }
                            var data = {
                                total: res.data.total,
                                rows: NewData
                            };
                            return data;
                        }
                    }
                });
            },
            sureLxSelect:function(){
                $('#lxxzModal').modal('hide');
                cxAlertOk("选择成功");
            },
            mySubmit:function () {
                dabh = this.clxx.dabh;
                dalx = this.dalxText;
                this.clxx.typeName = dalx;
                this.clxx.typeId = typeId;
                var bootstrapValidator1 = $("form").data('bootstrapValidator');
                bootstrapValidator1.validate();
                if(bootstrapValidator1.isValid()){
                    this.zzmySubmit = true;
                    this.$http.post('/dalr/api/clbr',this.clxx).then( function (result) {
                        this.zzmySubmit = false;
                        var data = result.body;
                        if(data.code == 200){

                            typeName = this.clxx.typeName;
                            typeId = this.clxx.typeId;
                            cxAlertOk("提交成功");
                            $("form").data('bootstrapValidator').resetForm();//清除当前验证的关键之处
                            Object.keys(this.clxx).forEach(key => (this.clxx[key] = null));
                            this.parentLx=null;
                            //this.dalx=null;
                            this.clxx.dabh = dabh;
                            this.clxx.typeName = typeName;
                            this.clxx.typeId = typeId;
                            $("#clTable").bootstrapTable('destroy');
                            $('#clTable').bootstrapTable({
                                url: '/dalr/api/queryDabhClxx?dabh='+this.clxx.dabh,
                                contentType: "application/json; charset=UTF-8",
                                type: "GET",
                                dataType: 'json',
                                queryParamsType: "",
                                singleSelect: true,
                                paginationShowPageGo: true,
                                pageNumber:1,
                                pageSize:8,
                                queryParams: function (params) {
                                    return {'pageNum':params.pageNumber,'pageSize':params.pageSize};
                                },
                                striped: true,
                                smartDisplay:false,
                                cache: false,
                                //pagination: true,
                                //pageList: [8],
                                sidePagination: 'server',
                                toolbar: "#addtool",
                                columns: [
                                    {
                                        title: '档案类型',
                                        field:'typeName',
                                        formatter:paramsMatter
                                    },{
                                        field: 'dabh',
                                        title: '档案编号',
                                        formatter:paramsMatter
                                    },
                                    {
                                        title: '文件序号',
                                        field:'wjxh',
                                        formatter:paramsMatter
                                    },{
                                        field: 'clxxName',
                                        title: '材料名称',
                                        formatter:paramsMatter
                                    }],
                                responseHandler: function (res) {  //后台返回的结果
                                    if (res.code == "200") {
                                        var data = res.data;
                                        var NewData = [];
                                        for(i=0;i<data.length;i++){
                                            var dd = data[i];
                                            NewData.push(dd);
                                        }
                                        var data = {
                                            total: res.data.total,
                                            rows: NewData
                                        };
                                        return data;
                                    }
                                }
                            });
                            //this.dalxText=null;
                            //top.refreshTab();
                        }else{
                            cxAlert(data.mess);
                            dabh = this.clxx.dabh;
                            $("form").data('bootstrapValidator').resetForm();//清除当前验证的关键之处
                            Object.keys(this.clxx).forEach(key => (this.clxx[key] = null));
                            this.parentLx=null;
                            this.dalx=null;
                            this.clxx.dabh = dabh;
                            this.clxx.typeName = typeName;
                            this.clxx.typeId = typeId;
                        }
                    })
                }
            }
        },
        mounted:function () {
            var that = this;
            var bh = location.search;

            if(bh.indexOf('&') != -1){
                bh = bh.substring(bh.indexOf('=')+1,bh.indexOf('&'));
            }else{
                bh = bh.substring(bh.indexOf('=')+1);
            }
            that.clxx.dabh = bh;
            var datas = bh.split("-");
            var code = datas[0];
            code = datas[0].substring(0,code.length-4)
            this.$http.get('/dagl/api/queryCode?code='+code).then( function (result) {
                var data = result.body;
                if (data.code == 200) {
                    this.parentLx = data.data.id;
                    this.dalx = data.data.id;
                    this.dalxText = data.data.dalxName;
                    this.clxx.typeId = data.data.id;
                    typeId = data.data.id;
                    typeName = data.data.dalxName;
                }
            });
            $("#clTable").bootstrapTable('destroy');
            $('#clTable').bootstrapTable({
                url: '/dalr/api/queryDabhClxx?dabh='+that.clxx.dabh,
                contentType: "application/json; charset=UTF-8",
                type: "GET",
                dataType: 'json',
                queryParamsType: "",
                singleSelect: true,
                paginationShowPageGo: true,
                pageNumber:1,
                pageSize:8,
                queryParams: function (params) {
                    return {'pageNum':params.pageNumber,'pageSize':params.pageSize};
                },
                striped: true,
                smartDisplay:false,
                cache: false,
                //pagination: true,
                //pageList: [8],
                sidePagination: 'server',
                toolbar: "#addtool",
                columns: [
                    {
                        title: '档案类型',
                        field:'typeName',
                        formatter:paramsMatter
                    },{
                        field: 'dabh',
                        title: '档案编号',
                        formatter:paramsMatter
                    },
                    {
                        title: '文件序号',
                        field:'wjxh',
                        formatter:paramsMatter
                    },{
                    field: 'clxxName',
                    title: '材料名称',
                        formatter:paramsMatter
                }],
                responseHandler: function (res) {  //后台返回的结果
                    if (res.code == "200") {
                        var data = res.data;
                        var NewData = [];
                        for(i=0;i<data.length;i++){
                            var dd = data[i];
                            NewData.push(dd);
                        }
                        var data = {
                            total: res.data.total,
                            rows: NewData
                        };
                        return data;
                    }
                }
            });
            //var that = this;
            $('form').bootstrapValidator({
                feedbackIcons: {
                    valid: 'glyphicon glyphicon-ok',
                    invalid: 'glyphicon glyphicon-remove',
                    validating: 'glyphicon glyphicon-refresh'
                },
                 fields: {
                     dalxText: {
                         validators: {
                             notEmpty: {
                                 message: '档案类型不能为空'
                             }
                         }
                     },
                    wjxh: {
                        validators: {
                            notEmpty: {
                                message: '文件序号不能为空'
                            },
                            stringLength: {
                                min: 3,
                                max: 3,
                                message: '文件序号必须为3位数字'
                            }
                        }
                    },
                    year: {
                        validators: {
                            digits: {
                                message: '年份只能包含数字。'
                            },
                            stringLength: {
                                min: 4,
                                max: 4,
                                message: '年份必须为4位数字'
                            }
                        }
                    },
                    ys: {
                        validators: {
                            digits: {
                                message: '页数只能包含数字。'
                            },
                            stringLength: {
                                max: 4,
                                message: '页数字段长度不能超过4'
                            }
                        }
                    },zzym: {
                        validators: {
                            digits: {
                                message: '终止页码只能包含数字。'
                            },
                            stringLength: {
                                max: 4,
                                message: '终止页码字段长度不能超过4'
                            }
                        }
                    },qsym: {
                        validators: {
                            digits: {
                                message: '起始页码只能包含数字。'
                            },
                            stringLength: {
                                max: 4,
                                message: '起始页码字段长度不能超过4'
                            }
                        }
                    },fs: {
                        validators: {
                            digits: {
                                message: '份数只能包含数字。'
                            },
                            stringLength: {
                                max: 11,
                                message: '份数字段长度不能超过11'
                            }
                        }
                    },
                    clmc: {
                        validators: {
                            notEmpty: {
                                message: '材料名称不能为空'
                            },
                            stringLength: {
                                max: 100,
                                message: '材料名称字段长度不能超过100'
                            }
                        }
                    },
                    // wjxh: {
                    //     validators: {
                    //         notEmpty: {
                    //             message: '文件序号不能为空'
                    //         }
                    //     }
                    // },
                    dabh: {
                        validators: {
                            notEmpty: {
                                message: '档案编号不能为空'
                            }
                        }
                    },
                     otherZh: {
                         validators: {
                             stringLength: {
                                 max: 50,
                                 message: '案卷号/文号/许可证号字段长度不能超过50'
                             }
                         }
                     },
                     bz: {
                         validators: {
                             stringLength: {
                                 max: 255,
                                 message: '备注字段长度不能超过255'
                             }
                         }
                     },
                     slsj: {
                         validators: {
                             stringLength: {
                                 max: 150,
                                 message: '受理时间字段长度不能超过150'
                             }
                         }
                     }
                }
            });
        }
    });



</script>

</body>
</html>
